package com.ruoyi.web.controller.gym;

import com.ny.domain.CheckInRecordDO;
import com.ny.dto.CheckInDTO;
import com.ny.dto.CreateGroup;
import com.ny.dto.PageResult;
import com.ny.dto.RestResult;
import com.ny.query.CheckInQuery;
import com.ny.query.QueryGroup;
import com.ny.service.CheckInService;
import com.ruoyi.common.core.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.lang.Boolean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 在线打卡管理模块
 *
 * @author MSI-NB
 * @date 2025-03-08 13:14:38
 */
@Api("在线打卡管理模块")
@RequestMapping("check-in")
@RestController
public class CheckInController extends BaseController {

    @Autowired
    private CheckInService checkInService;

    /**
     * 会员在线打卡
     *
     * @param checkInDTO 打卡信息入参
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation("会员在线打卡")
    @ResponseBody
    public RestResult<Boolean> checkIn(@RequestBody @Validated(CreateGroup.class) CheckInDTO checkInDTO) {
        Boolean result = checkInService.checkIn(checkInDTO);
        return RestResult.success(result);
    }

    /**
     * 查询会员打卡记录
     *
     * @param checkInQuery 打卡记录查询入参
     * @return
     */
    @RequestMapping(value = "/records", method = RequestMethod.GET)
    @ApiOperation("查询会员打卡记录")
    public RestResult<PageResult<CheckInRecordDO>> checkInRecords(@Validated(QueryGroup.class) CheckInQuery checkInQuery) {
        PageResult<CheckInRecordDO> result = checkInService.checkInRecords(checkInQuery);
        return RestResult.success(result);
    }
}
